import http from "@/api";

/**
 * 系统字典树形列表
 */
export const dictTreeApi = (params: object) => {
    return http.get(`/dict/tree`, params);
};

/**
 * 系统字典列表
 * @param params
 */
export const dictListApi = (params: object) => {
    return http.get("/dict/list", params);
}

/**
 * 新增字典
 * @param params
 */
export const addDictApi = (params: object) => {
    return http.post(`/dict/add`, params);
};

/**
 * 编辑字典
 * @param params
 */
export const editDictApi = (params: any) => {
    return http.put(`/dict/edit/${params.id}`, params);
};

/**
 * 切换字典状态
 * @param id
 */
export const changeStatusApi = (id: number) => {
    return http.put(`/dict/change_status/${id}`);
};

/**
 * 修改排序
 * @param params
 */
export const changeSortApi = (params: object) => {
    return http.post(`/dict/changeSort`, params);
};

/**
 * 删除字典
 * @param id
 */
export const deleteDictByIdApi = (id: number) => {
    return http.delete(`/dict/delete/${id}`);
};

/**
 * 批量删除
 * @param params
 */
export const deleteDictApi = (params: object) => {
    return http.post(`/dict/delete`, params);
};

/**
 * 字典值分页列表
 * @param params
 */
export const dictValuePageListApi = (params: object) => {
    return http.get(`/dict/value/paging`, params);
};

/**
 * 字典值列表
 * @param params
 */
export const dictValueListApi = (params: object) => {
    return http.get(`/dict/value/list`, params);
};

/**
 * 根据子安编码获取字典值列表
 * @param code
 */
export const dictValuesByDictCodeApi = (code: string) => {
    return http.get(`/dict/values/${code}`);
}

/**
 * 新增字典值
 * @param params
 */
export const addDictValueApi = (params: object) => {
    return http.post(`/dict/value/add`, params);
};

/**
 * 编辑字典值
 * @param params
 */
export const editDictValueApi = (params: any) => {
    return http.put(`/dict/value/edit/${params.id}`, params);
};

/**
 * 切换字典值状态
 * @param id
 */
export const changeValueStatusApi = (id: number) => {
    return http.put(`/dict/value/change_status/${id}`);
};

/**
 * 修改字典值通用扩展字段说明
 * @param params
 */
export const changeValueOtherTextApi = (params: object) => {
    return http.post(`/dict/value/changeOtherText`, params);
};

/**
 * 修改字典值排序
 * @param params
 */
export const changeValueSortApi = (params: object) => {
    return http.post(`/dict/value/changeSort`, params);
};

/**
 * 删除字典值
 * @param id
 */
export const deleteDictValueByIdApi = (id: number) => {
    return http.delete(`/dict/value/delete/${id}`);
};

/**
 * 批量删除
 * @param params
 */
export const deleteDictValueApi = (params: object) => {
    return http.post(`/dict/value/delete`, params);
};